package com.example.tx;


//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.JSON;

/**
 * @author 380276984@qq.com
 * @version 1.0.0
 * @date 2020/5/2 16:29
 */
public final class JsonUtil {
//    private static Logger log = LoggerFactory.getLogger(JsonUtil.class);


    public  static String toJson(Object obj){
        return JSON.toJSONString(obj);
    }

    public static <T> T fromJson(String json, Class<T> classOfT) throws Exception
    {
        try {
            return JSON.parseObject(json, classOfT);
        }
        catch (Exception e){
            System.out.println(e.getMessage());
//            log.error(e.getMessage());
            return  null;
        }

    }
}

